import request from '@/config/axios'

// 授权范围 VO
export interface ScopeVO {
  id: number // 序号
  name: string // 名称
  scope: string // 授权范围
  topic: string // 发布主题
  topicType: string // 主题类型
  brokerId: number // 所属转发
  groupId: number // 所属分组
  enable: boolean // 是否启用
}

// 授权范围 API
export const ScopeApi = {
  // 查询授权范围分页
  getScopePage: async (params: any) => {
    return await request.get({ url: `/forward/scope/page`, params })
  },

  // 查询授权范围详情
  getScope: async (id: number) => {
    return await request.get({ url: `/forward/scope/get?id=` + id })
  },

  // 新增授权范围
  createScope: async (data: ScopeVO) => {
    return await request.post({ url: `/forward/scope/create`, data })
  },

  // 修改授权范围
  updateScope: async (data: ScopeVO) => {
    return await request.put({ url: `/forward/scope/update`, data })
  },

  // 删除授权范围
  deleteScope: async (id: number) => {
    return await request.delete({ url: `/forward/scope/delete?id=` + id })
  },

  // 导出授权范围 Excel
  exportScope: async (params) => {
    return await request.download({ url: `/forward/scope/export-excel`, params })
  },

// ==================== 子表（授权范围信源关联） ====================

  // 获得授权范围信源关联列表
  getScopeResourceListByScopeId: async (scopeId) => {
    return await request.get({ url: `/forward/scope/scope-resource/list-by-scope-id?scopeId=` + scopeId })
  },
}